package com.vadmin.vadminjava.service;

import com.alibaba.fastjson.JSONObject;
import com.vadmin.vadminjava.db.DBUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/* ***********************************************************
 *
 * 用于记录事件的
 *
 * **********************************************************/
@Component
public class AdminLogService {


	private String TABLE_NAME = "log";//表名

	@Autowired
	CommonExtends commonExtends;

	//写入
	public void write(String title,Integer type,String remark){
		DBUtil dbUtil = new DBUtil();
		String sql = "INSERT INTO `"+ TABLE_NAME +"`( `title`, `type`, `remark`, `create_time`) " +
				"VALUES ( '"+title+"', '"+type+"', '"+remark+"', NOW())";
		//System.out.println(sql);
		try {
			dbUtil.insertOrUpdateInfoTONum(sql);
		} catch (Exception ex) {

		} finally {
			dbUtil.closeNoErr();
		}

	}

	//日志列表
	public JSONObject logsList(JSONObject params) {
		return commonExtends.commonDataList(params,"log");
	}

}
